package net.cyue.ort.llm.gui;

import javax.swing.filechooser.FileFilter;
import java.io.File;

public class FileFilterUtil {

    public static FileFilter createFileFilter(String... extensions) {
        return new FileFilter() {
            @Override
            public boolean accept(File f) {
                for (String ext : extensions) {
                    if (
                        f.isDirectory() ||
                        f.getName().toLowerCase().endsWith(ext)
                    ) {
                        return true;
                    }
                }
                return false;
            }

            @Override
            public String getDescription() {
                return String.join("/", extensions);
            }
        };
    }
}
